# coding:utf8

import MySQLdb

# 获取连接
conn = MySQLdb.connect(host='127.0.0.1', user='root', passwd='123456', charset='utf8', db='test')

# 获取普通游标
cursor = conn.cursor(MySQLdb.cursors.DictCursor)

# 查询SQL
sql = "select * from article_innodb;"
cursor.execute(sql)

rs = cursor.fetchall()
for row in rs:
    # 字典游标返回的数据是字典形式，可以用字段名访问数据
    print row['title'], row['content'], row['add_time']

# 关闭游标
cursor.close()
# 关闭连接
conn.close()
